package site.hanzhe.controller.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import site.hanzhe.entity.FieldEntity;
import site.hanzhe.oss.base.BaseOSS;
import site.hanzhe.service.FieldService;
import site.hanzhe.utils.R;

import java.io.InputStream;
import java.util.HashMap;

/**
 * 管理员公共接口
 */
@RestController("AdminAppController")
@RequestMapping("/api/admin")
public class AppController {

    @Autowired
    private BaseOSS oss;

    @PostMapping("/upload")
    public R upload(MultipartFile file) throws Exception {
        InputStream is = file.getInputStream();
        String fileName = file.getOriginalFilename();
        String upload = oss.upload(fileName, is);
        return R.success("图片上传成功！").setAttribute("path", upload);
    }

}